package com.slz3.business.module.goodsManagement.gooTypeLevel2.domain;

import com.slz3.business.frame.enums.AuditFlag;
import com.slz3.business.frame.enums.UsingFlag;
import com.slz3.business.frame.util.UUIDUtils;
import com.slz3.business.frame.util.VE;
import org.springframework.util.MultiValueMap;

import java.time.LocalDateTime;

public class GooTypeLevel2Factory {

    /**
     * 初始化基础属性值
     */
    public static GooTypeLevel2 initBaseFields(GooTypeLevel2 gooTypeLevel2) {
        if (gooTypeLevel2.getUuid() == null) {
            gooTypeLevel2.setUuid(UUIDUtils.generateUUID());
            gooTypeLevel2.setCreateTime(LocalDateTime.now());
            if (VE.isEmpty(gooTypeLevel2.getSerAudit())) {
                gooTypeLevel2.setSerAudit(AuditFlag.WAIT_SUBMIT);
            }
            if (VE.isEmpty(gooTypeLevel2.getSerUsing())) {
                gooTypeLevel2.setSerUsing(UsingFlag.ENABLE);
            }
        } else {
            gooTypeLevel2.setLastModifyTime(LocalDateTime.now());
        }
        return gooTypeLevel2;
    }

    public static GooTypeLevel2Condition newGooTypeLevel2Condition(MultiValueMap<String, String> params){
        GooTypeLevel2Condition condition = new GooTypeLevel2Condition();
        String oneId = params.getFirst("oneId");
        condition.setOneId(oneId);
        String gooType = params.getFirst("gooTypeName");
        condition.setGooTypeName(gooType);
        return condition;
    }

    /**
     * 初始化基础属性值
     */
    public static GooTypeLevel2 initBaseFields() {
        return initBaseFields(newTemStyle());
    }

    public static GooTypeLevel2 newTemStyle() {
        return new GooTypeLevel2();
    }

}
